package com.news.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.news.entity.News;
import com.news.entity.Page;
import com.news.service.NewsPageService;


@WebServlet("/adminnewslist")
public class AdminNewsListServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取用户单击的页码
		String current= request.getParameter("current");
		NewsPageService pageService=new NewsPageService();
		int curPage=(current==null?1: Integer.parseInt(current));
		List<News> news=pageService.getNewsByCurrentPage(curPage);
		List<Page> pages= pageService.getPages();
		request.setAttribute("news", news);//品牌列表
		request.setAttribute("pages", pages);//页码列表
		request.setAttribute("curPage", curPage);//当前页码
		request.setAttribute("pageCount", pages.size());//总页码
		request.getRequestDispatcher("/jsp/adminnewslist.jsp").forward(request, response);
	}
}
